package org.jivesoftware.smackx.pubsub;

import org.jivesoftware.smack.packet.PacketExtension;

public class Affiliation
  implements PacketExtension
{
  protected String node;
  protected Type type;

  public Affiliation(String paramString, Type paramType)
  {
    this.node = paramString;
    this.type = paramType;
  }

  private void appendAttribute(StringBuilder paramStringBuilder, String paramString1, String paramString2)
  {
    paramStringBuilder.append(" ");
    paramStringBuilder.append(paramString1);
    paramStringBuilder.append("='");
    paramStringBuilder.append(paramString2);
    paramStringBuilder.append("'");
  }

  public String getElementName()
  {
    return "subscription";
  }

  public String getNamespace()
  {
    return null;
  }

  public String getNodeId()
  {
    return this.node;
  }

  public Type getType()
  {
    return this.type;
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder("<");
    localStringBuilder.append(getElementName());
    appendAttribute(localStringBuilder, "node", this.node);
    appendAttribute(localStringBuilder, "affiliation", this.type.toString());
    localStringBuilder.append("/>");
    return localStringBuilder.toString();
  }

  public static enum Type
  {
    static
    {
      Type[] arrayOfType = new Type[5];
      arrayOfType[0] = member;
      arrayOfType[1] = none;
      arrayOfType[2] = outcast;
      arrayOfType[3] = owner;
      arrayOfType[4] = publisher;
      ENUM$VALUES = arrayOfType;
    }
  }
}